import request from '@/utils/request'
/**
 * 获取文章评论列表
 * @param {*} articleId 文章ID
 * @param {*} limit 每页显示条数
 * @returns
 */
export const reqGetArticleComments = (articleId, offset, limit = 10) => {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: articleId,
      offset,
      limit
    }
  })
}
/**
 * 获取评论回复
 * @param {*} commentId 评论Id
 * @param {*} limit 每页显示条数
 * @returns
 */
export const reqGetCommentReplay = (commentId, offset, limit = 10) => {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type: 'c',
      source: commentId,
      offset,
      limit
    }
  })
}
/**
 * 对评论或者评论回复点赞
 * @param {*} commentId 点赞的评论id或评论回复id
 * @returns
 */
export const reqCommentLike = (commentId) => {
  return request({
    url: '/v1_0/comment/likings',
    method: 'post',
    data: {
      target: commentId
    }
  })
}
/**
 *
 * @param {*} commentId 要取消点赞的评论id或评论回复id
 * @returns
 */
export const reqDelCommentLike = (commentId) => {
  return request({
    url: '/v1_0/comment/likings/' + commentId,
    method: 'delete'
  })
}
/**
 * 评论文章
 * @param {*} articleId 评论文章的Id
 * @param {*} content   评论内容
 * @returns
 */
export const reqAddComment = (articleId, content) => {
  return request({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target: articleId,
      content

    }
  })
}
export const reqAddReplay = (commentId, content, articleId) => {
  return request({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target: commentId,
      content,
      art_id: articleId
    }
  })
}
